﻿using Bilibili.Common.Api;
using Bilibili.Model.Resource;
using Bilibili.Model.User;
using PCLUntils.Json;
using System;
using System.Threading.Tasks;

namespace Bilibili.WebClient.Api
{
    public sealed class MessageClient : ClientBase
    {
        public async Task<ReturnModel<MessageReply>> GetNotify()
        {
            try
            {
                ApiInfo apiInfo = new ApiInfo("https://message.bilibili.com/api/notify/query.sysnotify.list.do", "&_ulv=10000&actionKey=appkey&data_type=1&page_size=40", true);
                string results = await ApiClient.GetResultsUTF8Encode(apiInfo);
                MessageReply model = results.ParseObject<MessageReply>();
                return BuildSuccessResult(model);
            }
            catch (Exception ex)
            {
                return BuildExceptionResult<MessageReply>(ex);
            }
        }
        public async Task<ReturnModel<MessageReply>> GetPraise()
        {
            try
            {
                ApiInfo apiInfo = new ApiInfo("http://message.bilibili.com/api/notify/query.praiseme.list.do", "&_ulv=10000&actionKey=appkey&data_type=1&page_size=40", true);
                string results = await ApiClient.GetResultsUTF8Encode(apiInfo);
                MessageReply model = results.ParseObject<MessageReply>();
                return BuildSuccessResult(model);
            }
            catch (Exception ex)
            {
                return BuildExceptionResult<MessageReply>(ex);
            }
        }
        public async Task<ReturnModel<MessageReply>> GetAtMe()
        {
            try
            {
                ApiInfo apiInfo = new ApiInfo("http://message.bilibili.com/api/notify/query.atme.list.do", "&_ulv=10000&actionKey=appkey&data_type=1&page_size=40", true);
                string results = await ApiClient.GetResultsUTF8Encode(apiInfo);
                MessageReply model = results.ParseObject<MessageReply>();
                return BuildSuccessResult(model);
            }
            catch (Exception ex)
            {
                return BuildExceptionResult<MessageReply>(ex);
            }
        }
        public async Task<ReturnModel<MessageReply>> GetReply()
        {
            try
            {
                ApiInfo apiInfo = new ApiInfo("http://message.bilibili.com/api/notify/query.replyme.list.do", "&_ulv=10000&data_type=1&page_size=40", true, ApiProviderBase.Build4);
                string results = await ApiClient.GetResultsUTF8Encode(apiInfo);
                MessageReply model = results.ParseObject<MessageReply>();
                return BuildSuccessResult(model);
            }
            catch (Exception ex)
            {
                return BuildExceptionResult<MessageReply>(ex);
            }
        }
    }
}